package com.fxcalibre.db.beans;

import javax.persistence.Embeddable;
import javax.persistence.ManyToOne;

@Embeddable
public class CrewPk implements java.io.Serializable
{
	private static final long serialVersionUID = 1L;
	private MediaItem mediaItem;
	private Person person;
	private String role;

	public CrewPk()
	{
		super();
	}

	public CrewPk(MediaItem mediaItem, Person person, String role)
	{
		super();
		this.mediaItem = mediaItem;
		this.person = person;
		this.role = role;
	}

	@ManyToOne
	public MediaItem getMediaItem()
	{
		return mediaItem;
	}

	public void setMediaItem(MediaItem mediaItem)
	{
		this.mediaItem = mediaItem;
	}

	@ManyToOne
	public Person getPerson()
	{
		return person;
	}

	public void setPerson(Person person)
	{
		this.person = person;
	}

	public String getRole()
	{
		return role;
	}

	public void setRole(String role)
	{
		this.role = role;
	}

	public boolean equals(Object o)
	{
		if (this == o)
			return true;
		if (o == null || getClass() != o.getClass())
			return false;

		CrewPk that = (CrewPk) o;

		if (mediaItem != null ? !mediaItem.equals(that.mediaItem) : that.mediaItem != null)
			return false;
		if (person != null ? !person.equals(that.person) : that.person != null)
			return false;

		if (role != null ? !role.equals(that.role) : that.role != null)
			return false;
		return true;
	}

	public int hashCode()
	{
		int result;
		result = (mediaItem != null ? mediaItem.hashCode() : 0);
		result = 31 * result + (person != null ? person.hashCode() : 0);
		result = 31 * result + (role != null ? role.hashCode() : 0);
		return result;
	}
}
